import params from "./params";
import req from './request.js'
import noti from'./notification.js'

export default{
	install(Vue){
		Vue.prototype.$req=req
        Vue.prototype.$params=params
		Vue.prototype.$noti=noti
		Vue.prototype.$formatTime=data =>{
			const formatNumber= n =>{
				n = n.toString()
				return n[1] ? n :`0${n}`
			}
			const year=data.getFullYear()
			const month=data.getMonth()+1
			const day=data.getDate()
			const hour=data.getHours()
			const minutes=data.getMinutes()
			const seconds=data.getSeconds()
			return `${[year,month,day].map(formatNumber).join('-')} ${[hour,minutes,seconds].map(formatNumber).join(':')}`
		}
		Vue.prototype.$checkLen = (field, len, name) => {
					if(field.length >= len){
						return true
					}
					let msg = name + "不能少于" + len + "个字符"
					if(field.length == 0){
						msg = name + "不能为空"
					}
					uni.showToast({
						title: msg,
						icon: "none"
					})
					return false
				}
	}
}